package com.eqdd.yiqidian.widget;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;

import com.bigkoo.alertview.AlertView;
import com.bigkoo.alertview.OnItemClickListener;

import java.util.List;

/**
 * Created by lzh on 17-2-24.
 */

public class ChooseAlertView {
    public static AlertView getAlertView(Activity activity, String[] chooseTexts, OnItemClickListener listener) {
        return new AlertView(null, null, null, null, chooseTexts,
                activity, AlertView.Style.ActionSheet, listener).
                setCancelable(true);
    }

    public static ActionSheetDialog getBottomChoose(Activity activity, String title, String[] chooseTexts, OnItemClickListener listener) {
        ActionSheetDialog actionSheetDialog = new ActionSheetDialog(activity)
                .builder()
                .setTitle(title)
                .setCancelable(true)
                .setCanceledOnTouchOutside(true)
                .setCancelVisible(true);
        for (int i = 0; i < chooseTexts.length; i++) {

            actionSheetDialog.addSheetItem(chooseTexts[i],
                    ActionSheetDialog.SheetItemColor.Blue,
                    (which) -> listener.onItemClick(null, which)
            );

        }
        return actionSheetDialog;
    }

    public static ActionSheetDialog getBottomChoose(Activity activity, String title, List<String> chooseTexts, OnItemClickListener listener) {
        ActionSheetDialog actionSheetDialog = new ActionSheetDialog(activity)
                .builder()
                .setTitle(title)
                .setCancelable(true)
                .setCanceledOnTouchOutside(true)
                .setCancelVisible(true);
        for (int i = 0; i < chooseTexts.size(); i++) {

            actionSheetDialog.addSheetItem(chooseTexts.get(i),
                    ActionSheetDialog.SheetItemColor.Blue,
                    (which) -> listener.onItemClick(null, which)
            );

        }
        return actionSheetDialog;
    }

    public static EditDialogFragment getEditDiglog(String title, String hint, String hint1, EditDialogFragment.OnClickListener listener) {
        EditDialogFragment editDialogFragment = new EditDialogFragment();
        Bundle bundle = new Bundle();
        bundle.putString("title", title);
        bundle.putString("hint", hint);
        bundle.putString("hint1", hint1);
        editDialogFragment.setArguments(bundle);
        editDialogFragment.setOnClickListener(listener);
        return editDialogFragment;
    }

    public static EditDialogFragment getEditDiglog(String title, String content, String hint, String content1, String hint1, EditDialogFragment.OnClickListener listener) {
        EditDialogFragment editDialogFragment = new EditDialogFragment();
        Bundle bundle = new Bundle();
        bundle.putString("title", title);
        bundle.putString("content", content);
        bundle.putString("hint", hint);
        bundle.putString("content1", content1);
        bundle.putString("hint1", hint1);
        editDialogFragment.setArguments(bundle);
        editDialogFragment.setOnClickListener(listener);
        return editDialogFragment;
    }

    public static AlertDialog getAlertTipDialog(Context context, String title, String message, EditDialogFragment.OnClickListener listener) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton("确认", (dialog, which) -> {
            dialog.dismiss();
            listener.onClick(null);
        });
        builder.setNegativeButton("取消", (DialogInterface dialog, int which) -> {
                    dialog.dismiss();
                }
        );
        return builder.create();


    }


}
